package com.edu.edumanager.vo;



import com.edu.edumanager.constant.EduConstant;

import java.util.HashMap;
import java.util.Map;

public class EduResult {
    //请求成功 请求失败
    private Boolean success;
    //请求状态码
    private Integer code;
    //请求消息
    private String message;
    //回传给页面的map集合
    private Map<String, Object> data = new HashMap<String, Object>();
    //静态方法可以直接通过类名.方法名直接调用 返回EduResult对象
    public static EduResult ok(){
        EduResult result = new EduResult();
        result.setSuccess(true);
        result.setCode(EduConstant.SUCCESS);
        result.setMessage("成功");
        return result;
    }
    //请求失败
    public static EduResult error(String message){
        EduResult result = new EduResult();
        result.setSuccess(false);
        result.setCode(EduConstant.ERROR);
        result.setMessage(message);
        return result;
    }
    //他是一个普通方法
    public EduResult data(String key, Object value){
        //往EduResult类里面的map集合里面添加数据
        this.data.put(key, value);
        return this;
    }


    public Boolean getSuccess() {
        return success;
    }
    public void setSuccess(Boolean success) {
        this.success = success;
    }
    public Integer getCode() {
        return code;
    }
    public void setCode(Integer code) {
        this.code = code;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public Map<String, Object> getData() {
        return data;
    }
    public void setData(Map<String, Object> data) {
        this.data = data;
    }
    @Override
    public String toString() {
        return "EduResult [success=" + success + ", code=" + code + ", message=" + message + ", data=" + data + "]";
    }



}

